/*******************************************************************************
 * Size: 10 px
 * Bpp: 4
 * Opts: --bpp 4 --size 10 --no-compress --font assets\fonts\SmileySans-Oblique.ttf --range 48-57 --format lvgl
 ******************************************************************************/

#ifdef __has_include
    #if __has_include("lvgl.h")
        #ifndef LV_LVGL_H_INCLUDE_SIMPLE
            #define LV_LVGL_H_INCLUDE_SIMPLE
        #endif
    #endif
#endif

#ifdef LV_LVGL_H_INCLUDE_SIMPLE
    #include "lvgl.h"
#else
    #include "lvgl/lvgl.h"
#endif

#ifndef UI_FONT_MY_FONT_10
#define UI_FONT_MY_FONT_10 1
#endif

#if UI_FONT_MY_FONT_10

/*-----------------
 *    BITMAPS
 *----------------*/

/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
    /* U+0030 "0" */
    0x2, 0xde, 0x30, 0xc4, 0x69, 0x1e, 0x5, 0xa4,
    0xb0, 0x69, 0x78, 0x9, 0x68, 0x70, 0xc3, 0x78,
    0x2d, 0x2, 0xed, 0x30,

    /* U+0031 "1" */
    0x0, 0x31, 0xe9, 0x8, 0x70, 0xa5, 0xc, 0x30,
    0xe1, 0xe, 0x2, 0xc0, 0x4a, 0x0,

    /* U+0032 "2" */
    0x0, 0x8e, 0xa0, 0x1, 0xa0, 0xe1, 0x0, 0x0,
    0xe0, 0x0, 0x9, 0x70, 0x0, 0x6b, 0x0, 0x2,
    0xd0, 0x0, 0xa, 0x50, 0x0, 0xe, 0xff, 0x50,

    /* U+0033 "3" */
    0x9, 0xea, 0x0, 0x70, 0xf0, 0x0, 0x4c, 0x0,
    0x8f, 0x30, 0x0, 0x6b, 0x0, 0x3, 0xc0, 0xe1,
    0x87, 0x7, 0xeb, 0x0,

    /* U+0034 "4" */
    0x0, 0x1, 0xf2, 0x0, 0x9, 0xf0, 0x0, 0x3a,
    0xd0, 0x0, 0xc5, 0xb0, 0x7, 0x66, 0x90, 0xe,
    0xef, 0xf1, 0x0, 0xa, 0x40, 0x0, 0xd, 0x20,

    /* U+0035 "5" */
    0xa, 0xee, 0x30, 0xc1, 0x0, 0xe, 0x0, 0x2,
    0xed, 0x70, 0x26, 0x2e, 0x0, 0x1, 0xd0, 0xd1,
    0x79, 0x7, 0xec, 0x10,

    /* U+0036 "6" */
    0x2, 0xde, 0x30, 0xb5, 0x46, 0x1e, 0x0, 0x4,
    0xdc, 0xa0, 0x7b, 0xc, 0x38, 0x60, 0xc3, 0x78,
    0x2e, 0x2, 0xdd, 0x40,

    /* U+0037 "7" */
    0x2e, 0xef, 0x30, 0x2, 0xc0, 0x0, 0xa4, 0x0,
    0x2d, 0x0, 0x8, 0x70, 0x0, 0xe2, 0x0, 0x2e,
    0x0, 0x6, 0xa0, 0x0,

    /* U+0038 "8" */
    0x6, 0xdd, 0x20, 0xf1, 0x87, 0xf, 0x1b, 0x40,
    0xaf, 0x90, 0x5a, 0x1e, 0x1a, 0x50, 0xd2, 0xa6,
    0x1e, 0x3, 0xdd, 0x40,

    /* U+0039 "9" */
    0x3, 0xdd, 0x20, 0xd3, 0x68, 0x2d, 0x5, 0x92,
    0xd0, 0xa8, 0x9, 0xcd, 0x60, 0x0, 0xd2, 0x55,
    0x4c, 0x2, 0xed, 0x20
};


/*---------------------
 *  GLYPH DESCRIPTION
 *--------------------*/

static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
    {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
    {.bitmap_index = 0, .adv_w = 78, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 20, .adv_w = 46, .box_w = 3, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 34, .adv_w = 67, .box_w = 6, .box_h = 8, .ofs_x = -1, .ofs_y = 0},
    {.bitmap_index = 58, .adv_w = 69, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 78, .adv_w = 71, .box_w = 6, .box_h = 8, .ofs_x = -1, .ofs_y = 0},
    {.bitmap_index = 102, .adv_w = 69, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 122, .adv_w = 76, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 142, .adv_w = 62, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 162, .adv_w = 75, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 182, .adv_w = 76, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0}
};

/*---------------------
 *  CHARACTER MAPPING
 *--------------------*/



/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
    {
        .range_start = 48, .range_length = 10, .glyph_id_start = 1,
        .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
    }
};

/*-----------------
 *    KERNING
 *----------------*/


/*Map glyph_ids to kern left classes*/
static const uint8_t kern_left_class_mapping[] =
{
    0, 1, 2, 3, 4, 5, 6, 7,
    8, 9, 10
};

/*Map glyph_ids to kern right classes*/
static const uint8_t kern_right_class_mapping[] =
{
    0, 1, 2, 3, 4, 5, 6, 7,
    8, 9, 10
};

/*Kern values between classes*/
static const int8_t kern_class_values[] =
{
    0, 0, -5, -2, 0, -2, 0, -5,
    -2, -3, 0, 0, 0, 0, 0, 0,
    0, 0, 0, -5, -2, 0, 0, -2,
    -3, 0, 0, -2, 0, -2, -2, 0,
    -3, 0, 0, 0, 0, -2, 0, -3,
    -2, 0, 0, 0, 0, 0, 0, -3,
    0, 0, 0, -2, 0, -2, 0, 0,
    0, -3, 0, -5, -2, -2, -2, -2,
    0, -2, -2, -3, 0, -5, -2, 0,
    0, 0, -10, -2, -2, 0, -2, -3,
    -3, -2, 0, 0, 0, -2, 0, -3,
    -2, -5, 0, 0, 0, 0, 0, 0,
    0, -2, 0, -2
};


/*Collect the kern class' data in one place*/
static const lv_font_fmt_txt_kern_classes_t kern_classes =
{
    .class_pair_values   = kern_class_values,
    .left_class_mapping  = kern_left_class_mapping,
    .right_class_mapping = kern_right_class_mapping,
    .left_class_cnt      = 10,
    .right_class_cnt     = 10,
};

/*--------------------
 *  ALL CUSTOM DATA
 *--------------------*/

#if LVGL_VERSION_MAJOR == 8
/*Store all the custom data of the font*/
static  lv_font_fmt_txt_glyph_cache_t cache;
#endif

#if LVGL_VERSION_MAJOR >= 8
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif
    .glyph_bitmap = glyph_bitmap,
    .glyph_dsc = glyph_dsc,
    .cmaps = cmaps,
    .kern_dsc = &kern_classes,
    .kern_scale = 16,
    .cmap_num = 1,
    .bpp = 4,
    .kern_classes = 1,
    .bitmap_format = 0,
#if LVGL_VERSION_MAJOR == 8
    .cache = &cache
#endif
};



/*-----------------
 *  PUBLIC FONT
 *----------------*/

/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t ui_font_my_font_10 = {
#else
lv_font_t ui_font_my_font_10 = {
#endif
    .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt,    /*Function pointer to get glyph's data*/
    .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt,    /*Function pointer to get glyph's bitmap*/
    .line_height = 9,          /*The maximum line height required by the font*/
    .base_line = 0,             /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
    .subpx = LV_FONT_SUBPX_NONE,
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8
    .underline_position = -1,
    .underline_thickness = 1,
#endif
    .dsc = &font_dsc,          /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9
    .fallback = NULL,
#endif
    .user_data = NULL,
};



#endif /*#if UI_FONT_MY_FONT_10*/

